package com.mohistmc.banner.gradle.task

import net.fabricmc.mappingio.MappingReader
import net.fabricmc.mappingio.MappingVisitor
import net.fabricmc.mappingio.MappingWriter
import net.fabricmc.mappingio.format.tiny.Tiny2FileWriter
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.TaskAction

import java.nio.file.Files

class ConvertSrgTask extends DefaultTask {

    @TaskAction
    void execute() {
        def srgFile = project.file("build/banner_cache/buildtools/BuildData/bukkit-mc-version-.srg")
        def tinyFile = project.file("build/tiny-mappings.tiny")

        // 使用Fabric mapping-io进行转换
        tinyFile.parentFile.mkdirs()
        /*
        MappingReader.read(srgFile.toPath(), new MappingVisitor() {
            @Override
            void visitNamespaces(String srcNamespace, List<String> dstNamespaces) {
                MappingWriter writer = new Tiny2FileWriter(Files.newBufferedWriter(tinyFile.toPath()), false)
                writer.visitNamespaces(srcNamespace, dstNamespaces)
            }

            // 实现其他映射处理逻辑（此处需根据SRG格式解析）
        })*/
    }
}